package com.ctgu.A1_4;

public class OrderDetail {
    //订单详情（OrderDetail）具有一个属性：数量（quantity），并具有calculateSubTotal（）、calculateWeight（）方法；
    private int quantity;
    private Product product;
    public double calculateSubTotal(){//订单详情的计算小计
        return product.getPrice()*this.quantity;
    }
    public double calculateWeight(){//订单详情的计算重量
        return product.getWeight()*this.quantity;
    }
    @Override
    public String toString() {
        return "订单详情{" +
                "商品名称=" + product.getTitle() +
                ", 数量=" + quantity +
                ", 小计价格=" + calculateSubTotal() +
                ", 小计重量=" + calculateWeight() +
                '}';
    }

    public OrderDetail() {
    }

    public OrderDetail(int quantity, Product product) {
        this.quantity = quantity;
        this.product = product;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
}
